package com.gagakuai.bpm.demo;

import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Component;

/*
 * @program: bpm_server
 * @description: 通过消息事件启动流程
 * @author: houhong
 * @create: 2022-07-21 10:33
 */
@Component(value = "instantiateProcessByMessageDelegate")
public class InstantiateProcessByMessageDelegate implements JavaDelegate {

    @Override
    public void execute(DelegateExecution execution) {
        String type = (String)execution.getVariable("type");
        RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService();
        if(type!=null && type.equals("tel")){
            runtimeService.startProcessInstanceByMessage("telMessage");
        }else{
            runtimeService.startProcessInstanceByMessage("pcMessage");
        }
    }
}